package com.eugene.dao;

import java.util.LinkedHashMap;
import java.util.Map;

import org.hibernate.Query;
import org.hibernate.Session;

import com.eugene.element.Property;
import com.eugene.util.HibernateUtil;

public class PropertyDao {
	private static Map<String, Property> prop = new LinkedHashMap<String, Property>();
	
	public static Property getProperity(String propId){
		if(! prop.containsKey(propId)){
			Session s = HibernateUtil.currentSession();
			Query qr =s.createQuery("from Property a where a.propertyId = :param");
			qr.setParameter("param", propId);
			prop.put(propId, (Property)qr.uniqueResult());
		}
		return prop.get(propId);
//		return (Property)qr.uniqueResult();
	}
	
}
